cmake_minimum_required(VERSION 3.10)
project(PdfReader LANGUAGES C)

find_package(PkgConfig REQUIRED)
pkg_check_modules(CAIRO REQUIRED cairo)
pkg_check_modules(X11 REQUIRED x11)
pkg_check_modules(FREETYPE REQUIRED freetype2)  # 新增FreeType
find_package(ZLIB REQUIRED)

include_directories(
    ${CAIRO_INCLUDE_DIRS}
    ${X11_INCLUDE_DIRS}
    ${FREETYPE_INCLUDE_DIRS}  # FreeType头文件
    ${ZLIB_INCLUDE_DIRS}
    src
)

set(SOURCES
    src/main.c
    src/pdf_parser.c
    src/renderer.c
    src/font_loader.c  # 新增字体加载模块
    src/search.c       # 新增搜索模块
)

link_libraries(
    ${CAIRO_LIBRARIES}
    ${X11_LIBRARIES}
    ${FREETYPE_LIBRARIES}  # 链接FreeType
    ${ZLIB_LIBRARIES}
)

add_executable(pdf_reader ${SOURCES})
target_compile_options(pdf_reader PRIVATE -Wall -Wextra)